package com.xtoneict;

import com.xtoneict.framework.expands.orm.api.Database;
import com.xtoneict.framework.util.json.JsonUtils;
import com.xtoneict.framework.util.spring.ApplicationContext;
import org.apache.commons.io.FileUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;


@SpringBootApplication
public class Test2 {



    public static void main(String[] args) throws Exception{
        SpringApplication.run(Test2.class, args);

        List<Area> areas = JsonUtils.readerList(FileUtils.readFileToString(new File("C:\\Users\\62772\\Desktop\\国家区划标准GB-T2260_2020_02_25发布streets.json"), "UTF-8"), Area.class);
        Database database = ApplicationContext.getCurrent().getBean(Database.class);
        for (Area area : areas) {
            database.getTable("districtsx", LinkedHashMap.class).createUpdate()
                    .is("name", area.getName())
                    .is("adcode", area.getAreaCode())
                    .set(new LinkedHashMap<String, Object>() {{
                        put("adcode", area.getCode());
                    }}).exec();
            System.out.println(area.toString());
        }
    }



}